﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JukeBoxLib
{
    public class Tracks
    {
        private List<Track> _tracks;

        public List<Track> Items {
            get
            {
                return _tracks;
            }
        }

        public Tracks()
        {
            _tracks = new List<Track>();
        }

        public void Add(string file)
        {
            Add(new System.IO.FileInfo(file));   
        }

        public void Add(System.IO.FileInfo file)
        {

            Track track = new Track(file.FullName);
            Track source_track = FindTrack(track);
            if (source_track != null)
            {
                source_track.Add(track);
            }
            else
            {
                _tracks.Add(track);
            }
        }

        public Track FindTrack(Track track)
        {
            foreach(Track t in _tracks) {
                if (t.IsEqual(track))
                    return t;
            }
            return null;
        }
    }
}
